#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int a = 0, b = 0, m = 0, n = 0, arr[10][10] = { 0 };
	scanf("%d %d", &m, &n);
	for (a = 0;a < m;a++)
	{
		for (b = 0;b < n;b++)
		{
			scanf("%d", &arr[a][b]);
		}
	}
	for (a = 0;a < n;a++)
	{
		for (b = 0;b < m;b++)
			printf("%d ", arr[b][a]);
		printf("\n");
	}
	return 0;
}